<template>
  <div class="app-container">
    <wms-form v-model:query-params="queryParams" :form-list="formList" @query="getList" label-width="88px"
      @export="handleExport">

    </wms-form>

    <wms-table :loading="loading" :data-list="stationList" :column="column" :pageInfo="queryParams"
      @get-list="getList" />

  </div>
</template>

<script setup name="Station">
import {
  listStation,
  getStation,
  delStation,
  addStation,
  updateStation,
} from "@/api/wms/station";
import WmsTable from '@/components/WmsTable/index.vue'
import WmsForm from '@/components/WmsForm/index.vue'
import { data, column, formList } from './index.js'
import { ref, reactive, getCurrentInstance, onMounted } from "vue";

const { proxy } = getCurrentInstance();
const queryParams = reactive(data.queryParams);

const stationList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);

/** 查询站台资料列表 */
function getList() {
  loading.value = true;
  listStation(proxy.addDateRange(queryParams, queryParams.dateRange)).then(
    (response) => {
      stationList.value = response.rows;
      queryParams.total = response.total;
      loading.value = false;
    }
  );
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  queryParams.dateRange = [];
  proxy.resetForm("queryRef");
  handleQuery();
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "wms/station/export",
    {
      ...queryParams,
    },
    `station_${new Date().getTime()}.xlsx`
  );
}

getList();
</script>
